import store from '../../store/store';
let JsObject;

//判断页面中是否引入了指定文件（.js 或者 .css）
export const isInclude = function (name) {
  let js= /js$/i.test(name);
  let es= document.getElementsByTagName(js? 'script' : 'link' );
  for ( let i=0; i<es.length; i++)
    if (es[i][js? 'src' : 'href' ].indexOf(name)!=-1) return true ;
  return false ;
};
//动态引入js文件，根据方法名返回方法
export const getJsMethod = async function (key) {
    if(JsObject && JsObject.mapName === store.state.currentFrameNameStore){
      return JsObject[key];
    }else {
      let tempName = store.state.currentFrameNameStore;
      JsObject = await import("../../script/"+ tempName +"Function/"+ tempName +"BaseF");
      return JsObject[key];
    }
};

